package com.fhao.common.rabbitmq;

import com.fhao.common.core.constants.RabbitMQConstants;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


//为了解决竞赛中大量用户同时在线答题的高并发场景而引入了rabbitmq.
//用户答题通过调用friend服务, 判题是judge服务, 所以friend是生产者,judge是消费者

@Configuration
public class RabbitConfig {

//    com.fhao.common.rabbit.RabbitConfig

    @Bean
    public Queue workQueue() {
        return new Queue(RabbitMQConstants.OJ_WORK_QUEUE, true);
    }

    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}











